﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Functionality
{
    class PersonHelper
    {
        public enum NameParseTechnique
        {
            OneAndOne,
            AllAndOne
        }
        
        public static NameParseTechnique NameParseTechniqueToUse { get; set; }


        public static string ParseFirstName(String name)
        {
            string[] names = name.Split(new char[] { ' ', '\t' });
            List<string> nameList = new List<string>(names);
            
            switch (NameParseTechniqueToUse)
            {
                case NameParseTechnique.AllAndOne:
                    nameList.RemoveAt(nameList.Count - 1);
                    return String.Join(" ", nameList);

                case NameParseTechnique.OneAndOne:
                default:
                    return names[0];
            }
        }

        public static string ParseLastName(string name)
        {
            string[] names = name.Split(new char[] { ' ', '\t' });
            return names[names.Length - 1];
        }

    }
}
